package com.lelefly.base.controller;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lelefly.base.model.Param;
import com.lelefly.base.model.Result;
import com.lelefly.base.po.UavMaintenance;
import com.lelefly.base.po.UavMissionTj;
import com.lelefly.base.serviceImp.UavMissionService;
import com.lelefly.constant.Constant;


@Controller
@RequestMapping("/uavmission")
public class UavMissionTjController extends BaseController{
	
	@Resource
	public UavMissionService service;
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping(value="/jsonapi/addUavMission",produces="application/json;charset=utf-8",consumes="application/json;charset=utf-8")
	@ResponseBody
	public Result UavMissionTj(@RequestBody String param){
		Result<UavMissionTj> result=new Result<>();
		try {
			Gson gson = new Gson();
			 Type type = new TypeToken<ArrayList<UavMissionTj>>() {
             }.getType();
             List<UavMissionTj> uavMissionTj = gson.fromJson(param, type);
			result = service.addUavMissionTj(uavMissionTj);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			result.setState(Constant.HTTP_STATUS_FAIL);
			getLogger().info("----->>"+e.getLocalizedMessage());
		}
		return result;
	}
	

}
